 #!/bin/sh
 # chkconfig: 123456 90 10
 #
 workdir=`pwd`

 daemon_start(){
   cd $workdir
   nohup python3 init.py > logfile.txt & echo $! > pidfile.txt
   echo "Server started."
 }

 daemon_stop(){
   cd $workdir
   pid=`cat pidfile.txt`
   echo $pid
   kill -9 $pid
   sleep 2
   echo "Server Killed."
 }

 case "$1" in
   start)
     daemon_start
     ;;
   stop)
     daemon_stop
     ;;
   restart)
     daemon_stop
     daemon_start
     ;;
   *)
   echo "Usage: Services {start|stop|restart}"
   exit 1
 esac
 exit 0

